package com.zbkj.service.model.dto;

import com.zbkj.dal.entity.order.Order;
import com.zbkj.service.model.front.req.order.LeaseProlongCalculateReq;
import com.zbkj.service.model.front.vo.order.LeaseOrderProlongCalculateVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@Data
public class OrderRentOverduePaymentRecordCreateDTO {

    @ApiModelProperty("订单号")
    private String orderNo;

    @ApiModelProperty("承享记录号")
    private String rentRecordCode;

    @ApiModelProperty("用户ID")
    private Integer uid;

    @ApiModelProperty(value = "支付交易类型")
    private String payTradeType;

    @ApiModelProperty(value = "订单商品总额")
    private BigDecimal totalAmount;

    @ApiModelProperty(value = "积分抵扣金额")
    private BigDecimal integralAmount;

    @ApiModelProperty(value = "逾期金额")
    private BigDecimal overdueAmount;

    @ApiModelProperty(value = "实际支付金额")
    private BigDecimal payAmount;

    @ApiModelProperty(value = "支付时间")
    private LocalDateTime payTime;

    @ApiModelProperty(value = "支付类型: MANUAL:手动支付， AUTO_INTEGRAL:自动扣款(雅识)")
    private String payType;

    @ApiModelProperty(value = "支付方式: weixin,alipay,yue")
    private String payMethod;

    @ApiModelProperty(value = "支付渠道：public-公众号,mini-小程序，h5-网页支付,yue-余额，wechatIos-微信Ios，wechatAndroid-微信Android,alipay-支付宝，alipayApp")
    private String payChannel;

    @ApiModelProperty(value = "支付状态：0 未付款 1 已付款")
    private Integer paidStatus;

    @ApiModelProperty(value = "退款状态：0 未退款 1 申请中 2 部分退款 3 已退款")
    private Integer refundStatus;


    public static OrderRentOverduePaymentRecordCreateDTO buildRentPayOrder(LeaseProlongCalculateReq req, Order order, LeaseOrderProlongCalculateVO calculateResult) {
        OrderRentOverduePaymentRecordCreateDTO orderRentOverduePaymentRecordCreateDTO = new OrderRentOverduePaymentRecordCreateDTO();
        orderRentOverduePaymentRecordCreateDTO.setOrderNo(req.getOrderNo());
        orderRentOverduePaymentRecordCreateDTO.setUid(order.getUid());
        orderRentOverduePaymentRecordCreateDTO.setPayTradeType("RENT_ORDER_PROLONG");
        orderRentOverduePaymentRecordCreateDTO.setTotalAmount(calculateResult.getTotalAmount());
        orderRentOverduePaymentRecordCreateDTO.setIntegralAmount(calculateResult.getDeductions());
        orderRentOverduePaymentRecordCreateDTO.setOverdueAmount(calculateResult.getTimeoutFee());
        orderRentOverduePaymentRecordCreateDTO.setPayAmount(calculateResult.getPayAmount());
        orderRentOverduePaymentRecordCreateDTO.setPayType("MANUAL");
        orderRentOverduePaymentRecordCreateDTO.setPayMethod("weixin");
        orderRentOverduePaymentRecordCreateDTO.setPayChannel("mini");
        orderRentOverduePaymentRecordCreateDTO.setPaidStatus(0);
        orderRentOverduePaymentRecordCreateDTO.setRefundStatus(0);
        return orderRentOverduePaymentRecordCreateDTO;
    }
}
